﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;

namespace DataVirtualization.Toolkit
{
    public class PaletteCollection:ObservableCollection<ResourceDictionary>
    {
        public LinearGradientBrush getPalette(int index)
        {
            if (this.Count == 0)
            {
                foreach (ResourceDictionary rs in LoadDefaults())
                {
                    this.Add(rs);
                }
            }
            if (this.Count > index)
            {
                return (LinearGradientBrush)this[index]["Background"];
            }
            return (LinearGradientBrush)this[0]["Background"];
        }

        public static PaletteCollection defaultSolidBrush()
        {
            PaletteCollection pallete = new PaletteCollection();
            SolidColorBrush brush = new SolidColorBrush();
            brush.Color = Windows.UI.Color.FromArgb(255,19,127,208);
            ResourceDictionary rs1 = new ResourceDictionary();
            rs1.Add("Background",brush);
            pallete.Add(rs1);
            return pallete;
        }

        public static PaletteCollection LoadDefaults()
        {
            PaletteCollection pallete = new PaletteCollection();
            //red
            LinearGradientBrush brush1 = new LinearGradientBrush();
            brush1.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush1.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush1.GradientStops.Add(new GradientStop());
            brush1.GradientStops.Add(new GradientStop());
            brush1.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 225, 31, 31);
            brush1.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 154, 34, 34);
            brush1.GradientStops[1].Offset = 1;
            ResourceDictionary rs1 = new ResourceDictionary();
            rs1.Add("Background", brush1);
            pallete.Add(rs1);
            //green
            LinearGradientBrush brush2 = new LinearGradientBrush();
            brush2.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush2.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush2.GradientStops.Add(new GradientStop());
            brush2.GradientStops.Add(new GradientStop());
            brush2.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 85, 224, 31);
            brush2.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 67, 150, 34);
            brush2.GradientStops[1].Offset = 1;
            ResourceDictionary rs2 = new ResourceDictionary();
            rs2.Add("Background", brush2);
            pallete.Add(rs2);
            //yellow
            LinearGradientBrush brush3 = new LinearGradientBrush();
            brush3.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush3.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush3.GradientStops.Add(new GradientStop());
            brush3.GradientStops.Add(new GradientStop());
            brush3.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 224, 222, 31);
            brush3.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 147, 150, 34);
            brush3.GradientStops[1].Offset = 1;
            ResourceDictionary rs3 = new ResourceDictionary();
            rs3.Add("Background", brush3);
            pallete.Add(rs3);
            //blue
            LinearGradientBrush brush4 = new LinearGradientBrush();
            brush4.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush4.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush4.GradientStops.Add(new GradientStop());
            brush4.GradientStops.Add(new GradientStop());
            brush4.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 13, 95, 167);
            brush4.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 36, 152, 225);
            brush4.GradientStops[1].Offset = 1;
            ResourceDictionary rs4 = new ResourceDictionary();
            rs4.Add("Background", brush4);
            pallete.Add(rs4);
            //purple
            LinearGradientBrush brush5 = new LinearGradientBrush();
            brush5.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush5.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush5.GradientStops.Add(new GradientStop());
            brush5.GradientStops.Add(new GradientStop());
            brush5.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 111, 16, 168);
            brush5.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 169, 25, 255);
            brush5.GradientStops[1].Offset = 1;
            ResourceDictionary rs5 = new ResourceDictionary();
            rs5.Add("Background", brush5);
            pallete.Add(rs5);
            //white
            LinearGradientBrush brush6 = new LinearGradientBrush();
            brush6.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush6.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush6.GradientStops.Add(new GradientStop());
            brush6.GradientStops.Add(new GradientStop());
            brush6.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 255, 255, 255);
            brush6.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 194, 194, 194);
            brush6.GradientStops[1].Offset = 1;
            ResourceDictionary rs6 = new ResourceDictionary();
            rs6.Add("Background", brush6);
            pallete.Add(rs6);

            LinearGradientBrush brush7 = new LinearGradientBrush();
            brush7.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush7.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush7.GradientStops.Add(new GradientStop());
            brush7.GradientStops.Add(new GradientStop());
            brush7.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 10, 55, 20);
            brush7.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 94, 150, 120);
            brush7.GradientStops[1].Offset = 1;
            ResourceDictionary rs7 = new ResourceDictionary();
            rs7.Add("Background", brush7);
            pallete.Add(rs7);

            LinearGradientBrush brush8 = new LinearGradientBrush();
            brush8.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush8.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush8.GradientStops.Add(new GradientStop());
            brush8.GradientStops.Add(new GradientStop());
            brush8.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 100, 55, 220);
            brush8.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 194, 150, 20);
            brush8.GradientStops[1].Offset = 1;
            ResourceDictionary rs8 = new ResourceDictionary();
            rs8.Add("Background", brush8);
            pallete.Add(rs8);

            LinearGradientBrush brush9 = new LinearGradientBrush();
            brush9.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush9.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush9.GradientStops.Add(new GradientStop());
            brush9.GradientStops.Add(new GradientStop());
            brush9.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 10, 155, 255);
            brush9.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 100, 150, 120);
            brush9.GradientStops[1].Offset = 1;
            ResourceDictionary rs9 = new ResourceDictionary();
            rs9.Add("Background", brush9);
            pallete.Add(rs9);

            LinearGradientBrush brush10 = new LinearGradientBrush();
            brush10.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush10.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush10.GradientStops.Add(new GradientStop());
            brush10.GradientStops.Add(new GradientStop());
            brush10.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 110, 85, 45);
            brush10.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 156, 110, 190);
            brush10.GradientStops[1].Offset = 1;
            ResourceDictionary rs10 = new ResourceDictionary();
            rs10.Add("Background", brush10);
            pallete.Add(rs10);

            LinearGradientBrush brush11 = new LinearGradientBrush();
            brush11.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush11.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush11.GradientStops.Add(new GradientStop());
            brush11.GradientStops.Add(new GradientStop());
            brush11.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 35, 175, 200);
            brush11.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 13, 150, 170);
            brush11.GradientStops[1].Offset = 1;
            ResourceDictionary rs11 = new ResourceDictionary();
            rs11.Add("Background", brush11);
            pallete.Add(rs11);

            LinearGradientBrush brush12 = new LinearGradientBrush();
            brush12.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush12.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush12.GradientStops.Add(new GradientStop());
            brush12.GradientStops.Add(new GradientStop());
            brush12.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 98, 113, 213);
            brush12.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 13, 225, 120);
            brush12.GradientStops[1].Offset = 1;
            ResourceDictionary rs12 = new ResourceDictionary();
            rs12.Add("Background", brush12);
            pallete.Add(rs12);

            LinearGradientBrush brush13 = new LinearGradientBrush();
            brush13.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush13.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush13.GradientStops.Add(new GradientStop());
            brush13.GradientStops.Add(new GradientStop());
            brush13.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 225, 0, 120);
            brush13.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 150, 50, 45);
            brush13.GradientStops[1].Offset = 1;
            ResourceDictionary rs13 = new ResourceDictionary();
            rs13.Add("Background", brush13);
            pallete.Add(rs13);

            LinearGradientBrush brush14 = new LinearGradientBrush();
            brush14.StartPoint = new Windows.Foundation.Point(0.5, 0);
            brush14.EndPoint = new Windows.Foundation.Point(0.5, 1);
            brush14.GradientStops.Add(new GradientStop());
            brush14.GradientStops.Add(new GradientStop());
            brush14.GradientStops[0].Color = Windows.UI.Color.FromArgb(255, 67, 215, 135);
            brush14.GradientStops[1].Color = Windows.UI.Color.FromArgb(255, 89, 135, 27);
            brush14.GradientStops[1].Offset = 1;
            ResourceDictionary rs14 = new ResourceDictionary();
            rs14.Add("Background", brush14);
            pallete.Add(rs14);

            return pallete;
        }
    }
}
